using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Net;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Windows.Forms;
using DukeyCssFetch.api;

namespace DukeyCssFetch
{
	// Token: 0x02000007 RID: 7
	public class BatDownLoadFrm : Form
	{
		// Token: 0x06000016 RID: 22 RVA: 0x00003324 File Offset: 0x00001524
		public BatDownLoadFrm(string curUrl, string folder)
		{
			this.list_0 = new List<string>();
			this.Restbytes = 1L;
			
			this.InitializeComponent();
			this.txtUrl.Text = curUrl;
			this.txtFolder.Text = folder;
			Control.CheckForIllegalCrossThreadCalls = false;
			this.cbbianma.SelectedIndex = 0;
		}

		// Token: 0x0600002B RID: 43 RVA: 0x000048E4 File Offset: 0x00002AE4
		private void BatDownLoadFrm_FormClosing(object sender, FormClosingEventArgs e)
		{
			if (this.thread_1 != null && this.thread_1.IsAlive)
			{
				this.thread_1.Abort();
				this.thread_1 = null;
			}
			this.thread_0 = null;
		}

		// Token: 0x06000026 RID: 38 RVA: 0x00004654 File Offset: 0x00002854
		private void btnALLDownload_Click(object sender, EventArgs e)
		{
			if (this.thread_1 == null)
			{
				this.thread_1 = new Thread(new ThreadStart(this.method_3));
			}
			if (this.thread_1.ThreadState == System.Threading.ThreadState.Unstarted)
			{
				this.thread_1.Start();
				this.btnALLDownload.Enabled = false;
			}
			if (this.thread_1.ThreadState == System.Threading.ThreadState.Suspended)
			{
				this.thread_1.Resume();
				this.btnALLDownload.Enabled = false;
			}
		}

		// Token: 0x0600001D RID: 29 RVA: 0x00003854 File Offset: 0x00001A54
		private void btnBrowser_Click(object sender, EventArgs e)
		{
			if (this.folderBrowserDialog_0.ShowDialog() == DialogResult.OK)
			{
				this.txtFolder.Text = this.folderBrowserDialog_0.SelectedPath;
			}
		}

		// Token: 0x06000029 RID: 41 RVA: 0x000047A8 File Offset: 0x000029A8
		private void btnContinue_Click(object sender, EventArgs e)
		{
			if (this.thread_1 != null && this.thread_1.IsAlive && (this.thread_1.ThreadState == System.Threading.ThreadState.SuspendRequested || this.thread_1.ThreadState == System.Threading.ThreadState.Suspended || (this.thread_1.ThreadState == System.Threading.ThreadState.SuspendRequested | this.thread_1.ThreadState == System.Threading.ThreadState.WaitSleepJoin)))
			{
				this.thread_1.Resume();
				this.btnContinue.Enabled = false;
				this.btnALLDownload.Enabled = false;
				this.btnPause.Enabled = true;
				this.btnStop.Enabled = true;
				this.lblTip.Text = "操作继续!";
			}
		}

		// Token: 0x06000017 RID: 23 RVA: 0x00003388 File Offset: 0x00001588
		private void btnFetchPage_Click(object sender, EventArgs e)
		{
			this.thread_0 = new Thread(new ThreadStart(this.method_0));
			this.thread_0.Start();
		}

		// Token: 0x0600002A RID: 42 RVA: 0x00004858 File Offset: 0x00002A58
		private void btnPause_Click(object sender, EventArgs e)
		{
			if (this.thread_1 != null && this.thread_1.IsAlive)
			{
				if (this.thread_1.ThreadState == System.Threading.ThreadState.Running || this.thread_1.ThreadState == System.Threading.ThreadState.WaitSleepJoin)
				{
					this.thread_1.Suspend();
				}
				this.lblTip.Text = "操作暂停!";
				this.btnContinue.Enabled = true;
				this.btnALLDownload.Enabled = false;
				this.btnPause.Enabled = false;
				this.btnStop.Enabled = true;
			}
		}

		// Token: 0x0600002E RID: 46 RVA: 0x00004AA4 File Offset: 0x00002CA4
		private void btnReBack_Click(object sender, EventArgs e)
		{
			this.listHtmlFile.Items.Clear();
			for (int i = 0; i < this.list_0.Count; i++)
			{
				ListViewItem listViewItem = new ListViewItem((i + 1).ToString());
				listViewItem.SubItems.Add(this.list_0[i]);
				this.listHtmlFile.Items.Add(listViewItem);
			}
		}

		// Token: 0x0600001F RID: 31 RVA: 0x000038B8 File Offset: 0x00001AB8
		private void btnRemoveSelectFiles_Click(object sender, EventArgs e)
		{
			foreach (ListViewItem listViewItem in this.listHtmlFile.SelectedItems)
			{
				listViewItem.Remove();
			}
		}

		// Token: 0x0600002C RID: 44 RVA: 0x00004914 File Offset: 0x00002B14
		private void btnSpecialKeys_Click(object sender, EventArgs e)
		{
			if (string.IsNullOrEmpty(this.txtSpecialKeys.Text.Trim()))
			{
				return;
			}
			string[] array = this.txtSpecialKeys.Text.Trim().Split(new char[]
			{
				'|'
			});
			string[] array2 = array;
			for (int i = 0; i < array2.Length; i++)
			{
				string text = array2[i];
				foreach (ListViewItem listViewItem in this.listHtmlFile.Items)
				{
					if (listViewItem.SubItems[1].Text.Contains(text.ToLower()))
					{
						listViewItem.Remove();
					}
				}
			}
		}

		// Token: 0x06000028 RID: 40 RVA: 0x000046FC File Offset: 0x000028FC
		private void btnStop_Click(object sender, EventArgs e)
		{
			this.lblTip.Text = "操作中止!";
			if (this.thread_1 != null && this.thread_1.IsAlive)
			{
				if (this.thread_1.ThreadState == System.Threading.ThreadState.Running || this.thread_1.ThreadState == System.Threading.ThreadState.WaitSleepJoin)
				{
					this.thread_1.Interrupt();
					this.thread_1.Abort();
				}
				this.lblTip.Text = "操作中止!";
				this.btnContinue.Enabled = false;
				this.btnALLDownload.Enabled = true;
				this.btnPause.Enabled = false;
				this.btnStop.Enabled = false;
			}
			this.thread_1 = null;
		}

		// Token: 0x0600002D RID: 45 RVA: 0x000049F0 File Offset: 0x00002BF0
		private void button2_Click(object sender, EventArgs e)
		{
			if (this.txtSame.Text.Trim() == "")
			{
				return;
			}
			int num = 0;
			foreach (ListViewItem listViewItem in this.listHtmlFile.Items)
			{
				if (listViewItem.SubItems[1].Text.Contains(this.txtSame.Text.Trim().ToLower()))
				{
					if (num > 0)
					{
						listViewItem.Remove();
					}
					num++;
				}
			}
		}

		// Token: 0x06000019 RID: 25 RVA: 0x00003708 File Offset: 0x00001908
		private void contextMenuStrip1_Opening(object sender, CancelEventArgs e)
		{
			if (this.listHtmlFile.SelectedItems.Count == 0)
			{
				this.contextMenuStrip1.Enabled = false;
				return;
			}
			if (this.listHtmlFile.SelectedItems.Count > 1)
			{
				this.contextMenuStrip1.Items[0].Enabled = false;
				this.contextMenuStrip1.Items[1].Enabled = false;
			}
			this.contextMenuStrip1.Enabled = true;
		}

		// Token: 0x06000030 RID: 48 RVA: 0x00004B88 File Offset: 0x00002D88
		protected override void Dispose(bool disposing)
		{
			if (disposing && this.icontainer_0 != null)
			{
				this.icontainer_0.Dispose();
			}
			base.Dispose(disposing);
		}

		// Token: 0x06000025 RID: 37 RVA: 0x0000446C File Offset: 0x0000266C
		public void Download(string url, string dir)
		{
			BatDownLoadFrm.smethod_0(ref url, ref dir);
			this.AllBytes = Comm.GetFileSize(url);
			string text = url.Substring(url.LastIndexOf("/") + 1);
			this.lblTip.Text = "正在下载:" + dir + text;
			string text2 = dir + text + ".tmp!";
			if (File.Exists(dir + text))
			{
				FileInfo fileInfo = new FileInfo(dir + text);
				if (fileInfo.Length == this.AllBytes)
				{
					return;
				}
			}
			long num = 0L;
			FileStream fileStream = null;
			if (File.Exists(text2))
			{
				try
				{
					fileStream = File.OpenWrite(text2);
					num = fileStream.Length;
					this.Downbytes = num;
					fileStream.Seek(num, SeekOrigin.Current);
				}
				catch
				{
					File.Delete(text2);
					this.Download(url, dir);
                    return;
				}
            }
            else
            {
                fileStream = new FileStream(text2, FileMode.Create);
                num = 0L;
            }
			try
			{
				HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(url);
				if (num > 0L)
				{
					httpWebRequest.AddRange((int)num);
				}
				Stream responseStream = httpWebRequest.GetResponse().GetResponseStream();
				this.Restbytes = httpWebRequest.GetResponse().ContentLength;
				byte[] buffer = new byte[512];
				int i = responseStream.Read(buffer, 0, 512);
				this.Downbytes += (long)i;
				while (i > 0)
				{
					fileStream.Write(buffer, 0, i);
					i = responseStream.Read(buffer, 0, 512);
					this.Downbytes += (long)i;
				}
				fileStream.Close();
				responseStream.Close();
				FileInfo fileInfo2 = new FileInfo(text2);
				fileInfo2.MoveTo(text2.Replace(".tmp!", ""));
				Console.WriteLine("下载完成");
			}
			catch (Exception)
			{
				fileStream.Close();
			}
		}

		// Token: 0x06000031 RID: 49 RVA: 0x00004BA8 File Offset: 0x00002DA8
		private void InitializeComponent()
		{
			this.icontainer_0 = new Container();
			ComponentResourceManager componentResourceManager = new ComponentResourceManager(typeof(BatDownLoadFrm));
			this.listHtmlFile = new ListView();
			this.columnHeader_0 = new ColumnHeader();
			this.columnHeader_1 = new ColumnHeader();
			this.contextMenuStrip1 = new ContextMenuStrip(this.icontainer_0);
			this.在浏览器打开ToolStripMenuItem = new ToolStripMenuItem();
			this.复制网址ToolStripMenuItem = new ToolStripMenuItem();
			this.分析该网页ToolStripMenuItem = new ToolStripMenuItem();
			this.从列表中移除ToolStripMenuItem = new ToolStripMenuItem();
			this.btnFetchPage = new Button();
			this.label3 = new Label();
			this.txtUrl = new TextBox();
			this.label1 = new Label();
			this.lblTip = new Label();
			this.btnRemoveSelectFiles = new Button();
			this.groupBox1 = new GroupBox();
			this.button2 = new Button();
			this.txtSame = new TextBox();
			this.btnSpecialKeys = new Button();
			this.label7 = new Label();
			this.txtSpecialKeys = new TextBox();
			this.label4 = new Label();
			this.btnBrowser = new Button();
			this.label5 = new Label();
			this.txtFolder = new TextBox();
			this.folderBrowserDialog_0 = new FolderBrowserDialog();
			this.chkIsFetchChildPage = new CheckBox();
			this.groupBox2 = new GroupBox();
			this.cbbianma = new ComboBox();
			this.label2 = new Label();
			this.btnALLDownload = new Button();
			this.btnStop = new Button();
			this.linkLabel1 = new LinkLabel();
			this.btnContinue = new Button();
			this.btnPause = new Button();
			this.toolTip_0 = new ToolTip(this.icontainer_0);
			this.btnReBack = new Button();
			this.contextMenuStrip1.SuspendLayout();
			this.groupBox1.SuspendLayout();
			this.groupBox2.SuspendLayout();
			base.SuspendLayout();
			this.listHtmlFile.AllowColumnReorder = true;
			this.listHtmlFile.Columns.AddRange(new ColumnHeader[]
			{
				this.columnHeader_0,
				this.columnHeader_1
			});
			this.listHtmlFile.ContextMenuStrip = this.contextMenuStrip1;
			this.listHtmlFile.FullRowSelect = true;
			this.listHtmlFile.Location = new Point(12, 194);
			this.listHtmlFile.Name = "listHtmlFile";
			this.listHtmlFile.Size = new Size(760, 358);
			this.listHtmlFile.TabIndex = 1;
			this.listHtmlFile.UseCompatibleStateImageBehavior = false;
			this.listHtmlFile.View = View.Details;
			this.columnHeader_0.Text = "序号";
			this.columnHeader_1.Text = "文件名";
			this.columnHeader_1.Width = 500;
			this.contextMenuStrip1.Items.AddRange(new ToolStripItem[]
			{
				this.在浏览器打开ToolStripMenuItem,
				this.复制网址ToolStripMenuItem,
				this.分析该网页ToolStripMenuItem,
				this.从列表中移除ToolStripMenuItem
			});
			this.contextMenuStrip1.Name = "contextMenuStrip1";
			this.contextMenuStrip1.Size = new Size(149, 92);
			this.contextMenuStrip1.Opening += new CancelEventHandler(this.contextMenuStrip1_Opening);
			this.在浏览器打开ToolStripMenuItem.Name = "在浏览器打开ToolStripMenuItem";
			this.在浏览器打开ToolStripMenuItem.Size = new Size(148, 22);
			this.在浏览器打开ToolStripMenuItem.Text = "在浏览器打开";
			this.在浏览器打开ToolStripMenuItem.Click += new EventHandler(this.在浏览器打开ToolStripMenuItem_Click);
			this.复制网址ToolStripMenuItem.Name = "复制网址ToolStripMenuItem";
			this.复制网址ToolStripMenuItem.Size = new Size(148, 22);
			this.复制网址ToolStripMenuItem.Text = "复制网址";
			this.复制网址ToolStripMenuItem.Click += new EventHandler(this.复制网址ToolStripMenuItem_Click);
			this.分析该网页ToolStripMenuItem.Name = "分析该网页ToolStripMenuItem";
			this.分析该网页ToolStripMenuItem.Size = new Size(148, 22);
			this.分析该网页ToolStripMenuItem.Text = "分析该网页";
			this.分析该网页ToolStripMenuItem.Click += new EventHandler(this.分析该网页ToolStripMenuItem_Click);
			this.从列表中移除ToolStripMenuItem.Name = "从列表中移除ToolStripMenuItem";
			this.从列表中移除ToolStripMenuItem.Size = new Size(148, 22);
			this.从列表中移除ToolStripMenuItem.Text = "从列表中移除";
			this.从列表中移除ToolStripMenuItem.Click += new EventHandler(this.从列表中移除ToolStripMenuItem_Click);
			this.btnFetchPage.Location = new Point(441, 10);
			this.btnFetchPage.Name = "btnFetchPage";
			this.btnFetchPage.Size = new Size(75, 23);
			this.btnFetchPage.TabIndex = 5;
			this.btnFetchPage.Text = "分析网页";
			this.btnFetchPage.UseVisualStyleBackColor = true;
			this.btnFetchPage.Click += new EventHandler(this.btnFetchPage_Click);
			this.label3.AutoSize = true;
			this.label3.Location = new Point(11, 15);
			this.label3.Name = "label3";
			this.label3.Size = new Size(59, 12);
			this.label3.TabIndex = 4;
			this.label3.Text = "当前网页:";
			this.txtUrl.Location = new Point(76, 12);
			this.txtUrl.Name = "txtUrl";
			this.txtUrl.Size = new Size(359, 21);
			this.txtUrl.TabIndex = 3;
			this.txtUrl.Text = "http://";
			this.label1.AutoSize = true;
			this.label1.Location = new Point(10, 174);
			this.label1.Name = "label1";
			this.label1.Size = new Size(95, 12);
			this.label1.TabIndex = 4;
			this.label1.Text = "该网页的子页面:";
			this.lblTip.AutoSize = true;
			this.lblTip.ForeColor = Color.Red;
			this.lblTip.Location = new Point(74, 76);
			this.lblTip.Name = "lblTip";
			this.lblTip.Size = new Size(143, 12);
			this.lblTip.TabIndex = 6;
			this.lblTip.Text = "欢迎你使用都客网页助手!";
			this.btnRemoveSelectFiles.Location = new Point(632, 169);
			this.btnRemoveSelectFiles.Name = "btnRemoveSelectFiles";
			this.btnRemoveSelectFiles.Size = new Size(140, 23);
			this.btnRemoveSelectFiles.TabIndex = 7;
			this.btnRemoveSelectFiles.Text = "移除选中的文件";
			this.btnRemoveSelectFiles.UseVisualStyleBackColor = true;
			this.btnRemoveSelectFiles.Click += new EventHandler(this.btnRemoveSelectFiles_Click);
			this.groupBox1.Controls.Add(this.button2);
			this.groupBox1.Controls.Add(this.txtSame);
			this.groupBox1.Controls.Add(this.btnSpecialKeys);
			this.groupBox1.Controls.Add(this.label7);
			this.groupBox1.Controls.Add(this.txtSpecialKeys);
			this.groupBox1.Controls.Add(this.label4);
			this.groupBox1.Location = new Point(12, 99);
			this.groupBox1.Name = "groupBox1";
			this.groupBox1.Size = new Size(760, 67);
			this.groupBox1.TabIndex = 10;
			this.groupBox1.TabStop = false;
			this.groupBox1.Text = "网页选项";
			this.button2.Location = new Point(558, 38);
			this.button2.Name = "button2";
			this.button2.Size = new Size(152, 23);
			this.button2.TabIndex = 5;
			this.button2.Text = "合并相似链接";
			this.button2.UseVisualStyleBackColor = true;
			this.button2.Click += new EventHandler(this.button2_Click);
			this.txtSame.Location = new Point(77, 40);
			this.txtSame.Name = "txtSame";
			this.txtSame.Size = new Size(475, 21);
			this.txtSame.TabIndex = 0;
			this.btnSpecialKeys.Location = new Point(558, 11);
			this.btnSpecialKeys.Name = "btnSpecialKeys";
			this.btnSpecialKeys.Size = new Size(152, 23);
			this.btnSpecialKeys.TabIndex = 5;
			this.btnSpecialKeys.Text = "过滤包含特定字符";
			this.btnSpecialKeys.UseVisualStyleBackColor = true;
			this.btnSpecialKeys.Click += new EventHandler(this.btnSpecialKeys_Click);
			this.label7.AutoSize = true;
			this.label7.Location = new Point(17, 44);
			this.label7.Name = "label7";
			this.label7.Size = new Size(59, 12);
			this.label7.TabIndex = 4;
			this.label7.Text = "相似网址:";
			this.txtSpecialKeys.Location = new Point(77, 13);
			this.txtSpecialKeys.Name = "txtSpecialKeys";
			this.txtSpecialKeys.Size = new Size(475, 21);
			this.txtSpecialKeys.TabIndex = 0;
			this.toolTip_0.SetToolTip(this.txtSpecialKeys, "多个关键字用\"|\"分隔,示例:abc|bcd|fdsd|fds");
			this.label4.AutoSize = true;
			this.label4.Location = new Point(17, 17);
			this.label4.Name = "label4";
			this.label4.Size = new Size(59, 12);
			this.label4.TabIndex = 4;
			this.label4.Text = "特定字符:";
			this.btnBrowser.Location = new Point(313, 40);
			this.btnBrowser.Name = "btnBrowser";
			this.btnBrowser.Size = new Size(75, 23);
			this.btnBrowser.TabIndex = 14;
			this.btnBrowser.Text = "浏览文件夹";
			this.btnBrowser.UseVisualStyleBackColor = true;
			this.btnBrowser.Click += new EventHandler(this.btnBrowser_Click);
			this.label5.AutoSize = true;
			this.label5.Location = new Point(23, 45);
			this.label5.Name = "label5";
			this.label5.Size = new Size(47, 12);
			this.label5.TabIndex = 13;
			this.label5.Text = "保存到:";
			this.txtFolder.Location = new Point(76, 42);
			this.txtFolder.Name = "txtFolder";
			this.txtFolder.Size = new Size(235, 21);
			this.txtFolder.TabIndex = 12;
			this.txtFolder.Text = "D:\\仿站";
			this.chkIsFetchChildPage.AutoSize = true;
			this.chkIsFetchChildPage.Checked = true;
			this.chkIsFetchChildPage.CheckState = CheckState.Checked;
			this.chkIsFetchChildPage.Location = new Point(16, 20);
			this.chkIsFetchChildPage.Name = "chkIsFetchChildPage";
			this.chkIsFetchChildPage.Size = new Size(84, 16);
			this.chkIsFetchChildPage.TabIndex = 16;
			this.chkIsFetchChildPage.Text = "分析子页面";
			this.chkIsFetchChildPage.UseVisualStyleBackColor = true;
			this.groupBox2.Controls.Add(this.cbbianma);
			this.groupBox2.Controls.Add(this.label2);
			this.groupBox2.Controls.Add(this.chkIsFetchChildPage);
			this.groupBox2.Location = new Point(566, 5);
			this.groupBox2.Name = "groupBox2";
			this.groupBox2.Size = new Size(206, 65);
			this.groupBox2.TabIndex = 17;
			this.groupBox2.TabStop = false;
			this.groupBox2.Text = "分析设置";
			this.cbbianma.DropDownStyle = ComboBoxStyle.DropDownList;
			this.cbbianma.FormattingEnabled = true;
			this.cbbianma.Items.AddRange(new object[]
			{
				"自动检测",
				"utf-8",
				"gb2312",
				"GBK",
				"Big5"
			});
			this.cbbianma.Location = new Point(79, 39);
			this.cbbianma.Name = "cbbianma";
			this.cbbianma.Size = new Size(108, 20);
			this.cbbianma.TabIndex = 18;
			this.label2.AutoSize = true;
			this.label2.Location = new Point(16, 42);
			this.label2.Name = "label2";
			this.label2.Size = new Size(59, 12);
			this.label2.TabIndex = 17;
			this.label2.Text = "网页编码:";
			this.btnALLDownload.Location = new Point(336, 169);
			this.btnALLDownload.Name = "btnALLDownload";
			this.btnALLDownload.Size = new Size(75, 23);
			this.btnALLDownload.TabIndex = 18;
			this.btnALLDownload.Text = "一键下载";
			this.btnALLDownload.UseVisualStyleBackColor = true;
			this.btnALLDownload.Click += new EventHandler(this.btnALLDownload_Click);
			this.btnStop.Enabled = false;
			this.btnStop.Location = new Point(539, 169);
			this.btnStop.Name = "btnStop";
			this.btnStop.Size = new Size(54, 23);
			this.btnStop.TabIndex = 19;
			this.btnStop.Text = "停止";
			this.btnStop.UseVisualStyleBackColor = true;
			this.btnStop.Click += new EventHandler(this.btnStop_Click);
			this.linkLabel1.AutoSize = true;
			this.linkLabel1.Location = new Point(394, 48);
			this.linkLabel1.Name = "linkLabel1";
			this.linkLabel1.Size = new Size(53, 12);
			this.linkLabel1.TabIndex = 20;
			this.linkLabel1.TabStop = true;
			this.linkLabel1.Text = "打开目录";
			this.linkLabel1.LinkClicked += new LinkLabelLinkClickedEventHandler(this.linkLabel1_LinkClicked);
			this.btnContinue.Enabled = false;
			this.btnContinue.Location = new Point(421, 169);
			this.btnContinue.Name = "btnContinue";
			this.btnContinue.Size = new Size(48, 23);
			this.btnContinue.TabIndex = 21;
			this.btnContinue.Text = "继续";
			this.btnContinue.UseVisualStyleBackColor = true;
			this.btnContinue.Click += new EventHandler(this.btnContinue_Click);
			this.btnPause.Enabled = false;
			this.btnPause.Location = new Point(481, 169);
			this.btnPause.Name = "btnPause";
			this.btnPause.Size = new Size(48, 23);
			this.btnPause.TabIndex = 22;
			this.btnPause.Text = "暂停";
			this.btnPause.UseVisualStyleBackColor = true;
			this.btnPause.Click += new EventHandler(this.btnPause_Click);
			this.toolTip_0.AutoPopDelay = 50000;
			this.toolTip_0.ForeColor = SystemColors.Highlight;
			this.toolTip_0.InitialDelay = 500;
			this.toolTip_0.ReshowDelay = 100;
			this.btnReBack.Location = new Point(128, 169);
			this.btnReBack.Name = "btnReBack";
			this.btnReBack.Size = new Size(75, 23);
			this.btnReBack.TabIndex = 23;
			this.btnReBack.Text = "还原列表";
			this.btnReBack.UseVisualStyleBackColor = true;
			this.btnReBack.Click += new EventHandler(this.btnReBack_Click);
			base.AutoScaleDimensions = new SizeF(6f, 12f);
			base.AutoScaleMode = AutoScaleMode.Font;
			base.ClientSize = new Size(784, 562);
			base.Controls.Add(this.btnReBack);
			base.Controls.Add(this.btnPause);
			base.Controls.Add(this.btnContinue);
			base.Controls.Add(this.btnStop);
			base.Controls.Add(this.linkLabel1);
			base.Controls.Add(this.btnBrowser);
			base.Controls.Add(this.btnALLDownload);
			base.Controls.Add(this.label5);
			base.Controls.Add(this.btnRemoveSelectFiles);
			base.Controls.Add(this.txtFolder);
			base.Controls.Add(this.lblTip);
			base.Controls.Add(this.btnFetchPage);
			base.Controls.Add(this.label1);
			base.Controls.Add(this.label3);
			base.Controls.Add(this.txtUrl);
			base.Controls.Add(this.listHtmlFile);
			base.Controls.Add(this.groupBox1);
			base.Controls.Add(this.groupBox2);
			base.Icon = (Icon)componentResourceManager.GetObject("$this.Icon");
			base.Name = "BatDownLoadFrm";
			base.StartPosition = FormStartPosition.CenterScreen;
			this.Text = "批量下载";
			base.FormClosing += new FormClosingEventHandler(this.BatDownLoadFrm_FormClosing);
			this.contextMenuStrip1.ResumeLayout(false);
			this.groupBox1.ResumeLayout(false);
			this.groupBox1.PerformLayout();
			this.groupBox2.ResumeLayout(false);
			this.groupBox2.PerformLayout();
			base.ResumeLayout(false);
			base.PerformLayout();
		}

		// Token: 0x06000027 RID: 39 RVA: 0x000046CC File Offset: 0x000028CC
		private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
		{
			if (Directory.Exists(this.txtFolder.Text.Trim()))
			{
				Process.Start(this.txtFolder.Text.Trim());
			}
		}

		// Token: 0x06000018 RID: 24 RVA: 0x000033AC File Offset: 0x000015AC
		private void method_0()
		{
			this.lblTip.Text = "正在分析网页子链接...";
			lock (this)
			{
				try
				{
					Control.CheckForIllegalCrossThreadCalls = false;
					this.btnFetchPage.Enabled = false;
					this.list_0.Clear();
					this.listHtmlFile.Items.Clear();
					string input = Comm.Html(this.txtUrl.Text.Trim(), this.method_5(this.txtUrl.Text.Trim()));
					string pattern = "<\\s*a\\shref=*[^>]*>([^<]|<(?!/a))*<\\s*/a\\s*>";
					string text = this.txtUrl.Text.Trim();
					int num = text.LastIndexOf("//");
					int num2 = text.LastIndexOf("/");
					string uriString = text.Remove(num2, text.Length - num2) + "/";
					if (num2 == num + 1)
					{
						uriString = text + "/";
					}
					Uri baseUri = new Uri(uriString);
					Regex regex = new Regex(pattern, RegexOptions.IgnoreCase);
					MatchCollection matchCollection = regex.Matches(input);
					for (int i = 0; i < matchCollection.Count; i++)
					{
						Match match = matchCollection[i];
						string value = match.Value;
						Regex regex2 = new Regex("href=[\"'](.*?)[\"']");
						Match match2 = regex2.Match(value);
						string text2 = match2.Value.ToLower();
						if (!text2.Contains(".css") && !text2.Contains(".js") && !text2.Contains(".gif") && !text2.Contains(".jpg") && !text2.Contains(".png") && !text2.Contains(".jpeg") && !text2.Contains(".ico") && !text2.Contains("javascript:") && !text2.Contains("mailto:"))
						{
							text2 = text2.Replace("href=", "");
							text2 = text2.Replace("\"", "");
							text2 = text2.Replace("'", "");
							text2.Remove(0, text2.LastIndexOf("/") + 1);
							if (!text2.Contains("http://") && !text2.Contains("https://"))
							{
								Uri uri = new Uri(baseUri, text2);
								text2 = uri.ToString();
							}
							if (!this.list_0.Contains(text2))
							{
								this.list_0.Add(text2);
							}
						}
					}
					for (int j = 0; j < this.list_0.Count; j++)
					{
						ListViewItem listViewItem = new ListViewItem((j + 1).ToString());
						listViewItem.SubItems.Add(this.list_0[j]);
						this.listHtmlFile.Items.Add(listViewItem);
					}
					this.lblTip.Text = "网页分析完成!";
				}
				catch (Exception ex)
				{
					this.lblTip.Text = ex.Message;
				}
			}
			this.btnFetchPage.Enabled = true;
			this.thread_0 = null;
		}

		// Token: 0x06000021 RID: 33 RVA: 0x00003A1C File Offset: 0x00001C1C
		private void method_1(string string_0)
		{
			this.lblTip.Text = "正在分析网页" + string_0;
			try
			{
				Encoding encoding = this.method_5(string_0);
				string text = Comm.Html(string_0, encoding);
				string text2 = text.ToLower();
				this.lblTip.Text = "发现" + string_0;
				string pattern = "<(link|script|embed).+?(href|src)=.+?>";
				int num = string_0.LastIndexOf("//");
				int num2 = string_0.LastIndexOf("/");
				string uriString = string_0.Remove(num2, string_0.Length - num2) + "/";
				if (num2 == num + 1)
				{
					uriString = string_0 + "/";
				}
				Uri uri = new Uri(uriString);
				//uri.Host += "\\";
				string text3 = this.txtFolder.Text.Trim().StartsWith("\\") ? this.txtFolder.Text.Trim() : (this.txtFolder.Text.Trim() + "\\");
				string string_ = "(?is)(?<=[\\s\\S]*url\\()[^)]+(?=\\))";
				string text4 = text2;
				text4 = text4.Replace("\"", "");
				text4 = text4.Replace("'", "");
				IList<string> list = this.method_4(text4, string_);
				for (int i = 0; i < list.Count; i++)
				{
					Uri uri2 = new Uri(uri, list[i]);
					this.lblTip.Text = "下载网页中的背景图片:" + uri2.ToString();
					Comm.api.Download(uri2.ToString(), text3);
				}
				string pattern2 = "import\\s+[^(\\']*[(\\']+([^)\\']+)";
				Regex regex = new Regex(pattern2, RegexOptions.IgnoreCase);
				MatchCollection matchCollection = regex.Matches(text2);
				for (int j = 0; j < matchCollection.Count; j++)
				{
					Match match = matchCollection[j];
					string text5 = match.Value.ToLower();
					text5 = text5.Replace("import", "");
					text5 = text5.Replace("url", "");
					text5 = text5.Replace("(", "");
					text5 = text5.Replace(")", "");
					text5 = text5.Replace(" ", "");
					text5 = text5.Replace("\"", "");
					text5.Remove(0, text5.LastIndexOf("/") + 1);
					if (!text5.Contains("http://") && !text5.Contains("https://"))
					{
						Uri uri3 = new Uri(uri, text5);
						text5 = uri3.ToString();
					}
					this.lblTip.Text = "正在下载@import中的css文件:" + text5;
					this.Download(text5, text3);
					this.method_2(text5, encoding, text3);
				}
				Regex regex2 = new Regex(pattern, RegexOptions.IgnoreCase);
				MatchCollection matchCollection2 = regex2.Matches(text2);
				for (int k = 0; k < matchCollection2.Count; k++)
				{
					Match match2 = matchCollection2[k];
					string value = match2.Value;
					Regex regex3 = new Regex("href=[\"'](.*?)[\"']");
					Match match3 = regex3.Match(value);
					string text6 = match3.Value.ToLower();
					if (text6.Contains(".css"))
					{
						text6 = text6.Replace("href=", "");
						text6 = text6.Replace("\"", "");
						text6 = text6.Replace("'", "");
						text6.Remove(0, text6.LastIndexOf("/") + 1);
						if (!text6.Contains("http://") && !text6.Contains("https://"))
						{
							Uri uri4 = new Uri(uri, text6);
							text6 = uri4.ToString();
						}
						this.lblTip.Text = "正在下载css文件:" + text6;
						this.Download(text6, text3);
						this.method_2(text6, encoding, text3);
					}
					Regex regex4 = new Regex("src=[\"'](.*?)[\"']");
					Match match4 = regex4.Match(value);
					string text7 = match4.Value.ToLower();
					if (text7.Contains(".js") || text7.Contains(".swf"))
					{
						text7 = text7.Replace("src=", "");
						text7 = text7.Replace("\"", "");
						text7 = text7.Replace("'", "");
						text7.Remove(0, text7.LastIndexOf("/") + 1);
						if (!text7.Contains("http://") && !text7.Contains("https://"))
						{
							Uri uri5 = new Uri(uri, text7);
							text7 = uri5.ToString();
						}
						Comm.api.Download(text7, text3);
					}
				}
				this.lblTip.Text = "正在分析网页中的图片...";
				string string_2 = "src=(.*?)[^>]*?>";
				IList<string> list2 = this.method_4(text2, string_2);
				foreach (string current in list2)
				{
					Regex regex5 = new Regex("src=[\"'](.*?)[\"']");
					Match match5 = regex5.Match(current);
					string text8 = match5.Value.ToLower();
					if (text8.Contains(".jpg") || text8.Contains(".gif") || text8.Contains(".png"))
					{
						text8 = text8.Replace("src=", "");
						text8 = text8.Replace("\"", "");
						text8 = text8.Replace("'", "");
						text8.Remove(0, text8.LastIndexOf("/") + 1);
						if (!text8.Contains("http://") && !text8.Contains("https://"))
						{
							Uri uri6 = new Uri(uri, text8);
							text8 = uri6.ToString();
						}
						this.lblTip.Text = "正在下载网页中的图片:" + text8;
						Comm.api.Download(text8, text3);
					}
				}
				this.lblTip.Text = "正在保存网页源文件...";
				string text9 = string_0;
				string text10 = text9.Remove(0, text9.LastIndexOf("/") + 1);
				if (num2 != num + 1 && !(text10 == "") && !text10.Contains("?") && !text10.StartsWith("&"))
				{
					if (text10.IndexOf('.') < 0)
					{
						text10 += ".html";
					}
					else
					{
						text10 = text10.Substring(0, text10.IndexOf('.')) + ".html";
					}
				}
				else
				{
					text10 = "index" + DateTime.Now.ToString("ff") + ".html";
				}
				BatDownLoadFrm.smethod_0(ref text9, ref text3);
				Comm.WriteFile(text3 + text10, text, encoding);
				this.lblTip.Text = "任务完成!";
			}
			catch (Exception ex)
			{
				this.lblTip.Text = ex.Message;
			}
		}

		// Token: 0x06000022 RID: 34 RVA: 0x0000416C File Offset: 0x0000236C
		private void method_2(string string_0, Encoding encoding_0, string string_1)
		{
			this.lblTip.Text = "正在提取css中背景图片...";
			try
			{
				int num = string_0.LastIndexOf("/");
				string uriString = string_0.Remove(num, string_0.Length - num) + "/";
				Uri baseUri = new Uri(uriString);
				string text = Comm.Html(string_0, encoding_0);
				string string_2 = "(?is)(?<=[\\s\\S]*url\\()[^)]+(?=\\))";
				text = text.Replace("\"", "");
				text = text.Replace("'", "");
				IList<string> list = this.method_4(text, string_2);
				for (int i = 0; i < list.Count; i++)
				{
					Uri uri = new Uri(baseUri, list[i]);
					if (list[i].Contains(".css"))
					{
						this.lblTip.Text = "发现@import css" + list[i];
						this.method_2(uri.ToString(), encoding_0, string_1);
					}
					this.lblTip.Text = "正在下载背景图片:" + uri.ToString();
					Comm.api.Download(uri.ToString(), string_1);
				}
				this.lblTip.Text = "提取背景图片成功,正在分析下一步...";
			}
			catch (Exception ex)
			{
				this.lblTip.Text = ex.Message;
			}
		}

		// Token: 0x06000023 RID: 35 RVA: 0x000042DC File Offset: 0x000024DC
		private void method_3()
		{
			this.btnALLDownload.Enabled = false;
			this.btnContinue.Enabled = false;
			this.btnPause.Enabled = true;
			this.btnStop.Enabled = true;
			this.method_1(this.txtUrl.Text.Trim());
			if (this.chkIsFetchChildPage.Checked)
			{
				foreach (ListViewItem listViewItem in this.listHtmlFile.Items)
				{
					string text = listViewItem.SubItems[1].Text;
					this.method_1(text);
				}
			}
			this.btnALLDownload.Enabled = true;
			this.btnContinue.Enabled = false;
			this.btnPause.Enabled = false;
			this.btnStop.Enabled = false;
			this.thread_1 = null;
		}

		// Token: 0x06000024 RID: 36 RVA: 0x000043D8 File Offset: 0x000025D8
		private IList<string> method_4(string string_0, string string_1)
		{
			IList<string> list = new List<string>();
			Regex regex = new Regex(string_1, RegexOptions.IgnoreCase);
			MatchCollection matchCollection = regex.Matches(string_0);
			if (matchCollection != null && matchCollection.Count > 0)
			{
				foreach (Match match in matchCollection)
				{
					if (!list.Contains(match.Value))
					{
						list.Add(match.Value);
					}
				}
			}
			return list;
		}

		// Token: 0x0600002F RID: 47 RVA: 0x00004B14 File Offset: 0x00002D14
		private Encoding method_5(string string_0)
		{
			Encoding result = Encoding.UTF8;
			switch (this.cbbianma.SelectedIndex)
			{
			case 0:
				result = Comm.GetPageEncoding(string_0);
				return result;
			case 2:
				result = Encoding.GetEncoding("gb2312");
				return result;
			case 3:
				result = Encoding.GetEncoding("gbk");
				return result;
			case 4:
				result = Encoding.GetEncoding("big5");
				return result;
			}
			result = Encoding.UTF8;
			return result;
		}

		// Token: 0x06000020 RID: 32 RVA: 0x00003918 File Offset: 0x00001B18
		private static void smethod_0(ref string string_0, ref string string_1)
		{
			try
			{
				if (string_0.Contains("?"))
				{
					string_0 = string_0.Remove(string_0.IndexOf("?"), string_0.Length - string_0.IndexOf("?"));
				}
				if (!string_1.EndsWith("\\"))
				{
					string_1 = string_1.Replace("/", "") + "\\";
				}
				Uri uri = new Uri(string_0);
				string str = uri.Host + "\\";
				string text = string_0.Replace("//", "");
				int num = text.IndexOf("/");
				int num2 = text.LastIndexOf("/");
				text = text.Substring(num + 1, num2 - num);
				text = text.Replace("/", "\\");
				string_1 = string_1 + str + text;
				if (!Directory.Exists(string_1))
				{
					Directory.CreateDirectory(string_1);
				}
			}
			catch
			{
			}
		}

		// Token: 0x0600001C RID: 28 RVA: 0x000037F4 File Offset: 0x000019F4
		private void 从列表中移除ToolStripMenuItem_Click(object sender, EventArgs e)
		{
			foreach (ListViewItem listViewItem in this.listHtmlFile.SelectedItems)
			{
				listViewItem.Remove();
			}
		}

		// Token: 0x0600001E RID: 30 RVA: 0x0000387C File Offset: 0x00001A7C
		private void 分析该网页ToolStripMenuItem_Click(object sender, EventArgs e)
		{
			string text = this.listHtmlFile.SelectedItems[0].SubItems[1].Text;
			this.txtUrl.Text = text;
		}

		// Token: 0x0600001A RID: 26 RVA: 0x00003784 File Offset: 0x00001984
		private void 在浏览器打开ToolStripMenuItem_Click(object sender, EventArgs e)
		{
			string text = this.listHtmlFile.SelectedItems[0].SubItems[1].Text;
			Process.Start(text);
		}

		// Token: 0x0600001B RID: 27 RVA: 0x000037BC File Offset: 0x000019BC
		private void 复制网址ToolStripMenuItem_Click(object sender, EventArgs e)
		{
			string text = this.listHtmlFile.SelectedItems[0].SubItems[1].Text;
			Clipboard.SetText(text);
		}

		// Token: 0x04000029 RID: 41
		public long AllBytes;

		// Token: 0x04000043 RID: 67
		private Button btnALLDownload;

		// Token: 0x0400003B RID: 59
		private Button btnBrowser;

		// Token: 0x04000046 RID: 70
		private Button btnContinue;

		// Token: 0x0400002E RID: 46
		private Button btnFetchPage;

		// Token: 0x04000047 RID: 71
		private Button btnPause;

		// Token: 0x0400004C RID: 76
		private Button btnReBack;

		// Token: 0x04000033 RID: 51
		private Button btnRemoveSelectFiles;

		// Token: 0x04000042 RID: 66
		private Button btnSpecialKeys;

		// Token: 0x04000044 RID: 68
		private Button btnStop;

		// Token: 0x04000048 RID: 72
		private Button button2;

		// Token: 0x0400004D RID: 77
		private ComboBox cbbianma;

		// Token: 0x04000040 RID: 64
		private CheckBox chkIsFetchChildPage;

		// Token: 0x0400002C RID: 44
		private ColumnHeader columnHeader_0;

		// Token: 0x0400002D RID: 45
		private ColumnHeader columnHeader_1;

		// Token: 0x04000037 RID: 55
		private ContextMenuStrip contextMenuStrip1;

		// Token: 0x04000028 RID: 40
		public long Downbytes;

		// Token: 0x0400003E RID: 62
		private FolderBrowserDialog folderBrowserDialog_0;

		// Token: 0x04000034 RID: 52
		private GroupBox groupBox1;

		// Token: 0x04000041 RID: 65
		private GroupBox groupBox2;

		// Token: 0x0400002A RID: 42
		private IContainer icontainer_0;

		// Token: 0x04000031 RID: 49
		private Label label1;

		// Token: 0x0400004E RID: 78
		private Label label2;

		// Token: 0x0400002F RID: 47
		private Label label3;

		// Token: 0x04000036 RID: 54
		private Label label4;

		// Token: 0x0400003C RID: 60
		private Label label5;

		// Token: 0x0400004A RID: 74
		private Label label7;

		// Token: 0x04000027 RID: 39
		public long lastlength;

		// Token: 0x04000032 RID: 50
		private Label lblTip;

		// Token: 0x04000045 RID: 69
		private LinkLabel linkLabel1;

		// Token: 0x0400002B RID: 43
		private ListView listHtmlFile;

		// Token: 0x04000024 RID: 36
		private List<string> list_0;

		// Token: 0x04000026 RID: 38
		public long Restbytes;

		// Token: 0x04000023 RID: 35
		private Thread thread_0;

		// Token: 0x04000025 RID: 37
		private Thread thread_1;

		// Token: 0x0400004B RID: 75
		private ToolTip toolTip_0;

		// Token: 0x0400003D RID: 61
		private TextBox txtFolder;

		// Token: 0x04000049 RID: 73
		private TextBox txtSame;

		// Token: 0x04000035 RID: 53
		private TextBox txtSpecialKeys;

		// Token: 0x04000030 RID: 48
		private TextBox txtUrl;

		// Token: 0x0400003A RID: 58
		private ToolStripMenuItem 从列表中移除ToolStripMenuItem;

		// Token: 0x0400003F RID: 63
		private ToolStripMenuItem 分析该网页ToolStripMenuItem;

		// Token: 0x04000038 RID: 56
		private ToolStripMenuItem 在浏览器打开ToolStripMenuItem;

		// Token: 0x04000039 RID: 57
		private ToolStripMenuItem 复制网址ToolStripMenuItem;
	}
}
